home *** CD-ROM | disk | FTP | other *** search
/ Zoom 2 / Zoom - Release 2 (1996)(Active Software)[!].iso / misc / scion409 / scionarexx.lha / Anniversary.rexx < prev    next >
OS/2 REXX Batch file  |  1993-10-24  |  11KB  |  442 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /*                            Anniversary.rexx                              */
  4. /*                                                                          */
  5. /* Written by: Peter Billing, RMB 1240, Yinnar 3869, Australia              */
  6. /*                                                                          */
  7. /* Last saved: Wednesday 29-Sep-93                                          */
  8. /*                                                                          */
  9. /* This script should tell you the Age of a person in the SCION database.   */
  10. /* It does except the date to be in the format DD MMM                       */
  11. /* The database must be running for this AREXX script to work.              */
  12. /*                                                                          */
  13. /****************************************************************************/
  14.  
  15. /* Return the Database Name */
  16.  
  17. options results
  18. /*test = show('P','SCIONGEN')
  19. if test = 0  then
  20. say
  21. say "I am sorry to say that the SCION Genealogist database is not available."
  22. say "Please start the SCION program BEFORE using this script."
  23. say
  24. exit */
  25.  
  26. myport = "SCIONGEN"
  27. address value myport
  28. getdbname
  29. dbname = upper(result)
  30. output = "STDOUT"
  31. out = "S"
  32. say " "
  33. say center("Anniversary.rexx",80)
  34. say
  35. say center("The current database name is "dbname,80)
  36. say "This script will tell you what Anniversaries occurr on a certain date."
  37. say "There are two forms to the date, DD MMM which will give Anniversaries"
  38. say "on that date ONLY and MMM which will give ALL Anniversaries of the Month."
  39. say "All Anniversaries are checked: Birth, Death, Burial and Marriage."
  40.  
  41. writech(output, "Type in the DATE you are interested in, in the formatt DD MMM. ")
  42. pull Anni_Date
  43. if date1 = "" then exit
  44. writech(output,"Output to Screen or File. S/F ")
  45. pull out
  46. if out = "" then out ="S"
  47. if out = "F" then do
  48.    filename = "RAM:Anniversary_"dbname".Scion"
  49.    open(w_file,filename,"w")
  50.    output = w_file
  51.    writeln(stdout,"")
  52.    writeln(stdout,"Writing file to" filename)
  53.    end
  54.  
  55. if words(Anni_date) = 1 & Anni_Date ~= "ALL" then do
  56.   checkmonth(Anni_Date)
  57.   start = x
  58.   finish = x
  59.   ending = "in the month of "
  60.   end
  61.  
  62. if Anni_Date = "ALL" then do
  63.   start = 1
  64.   finish = 12
  65.   ending = "in the month of "
  66.   end
  67.  
  68. if words(Anni_Date) = 2 then do
  69.   checkmonth(subword(Anni_Date,2))
  70.   start = x
  71.   finish = x
  72.   ending = "on this day "
  73.   end
  74.  
  75. date1 = Anni_Date
  76.  
  77. gettotalirn
  78. total = result
  79. do zz = start to finish
  80. if Anni_Date = "ALL" then do
  81.   getmonth(zz)
  82.   date1 = m
  83.   if out = "F" & zz > 1 then writeln(output," ")
  84. end
  85. say center("Checking the month of "m,80)
  86. writeln(output,"")
  87. writeln(output,center("The following people have birthdays "ending date1".",80))
  88. writeln(output,"-------------------------------------------------------------------------------")
  89. if out = "F" then writech(stdout,"Checking Birth records. ")
  90. printed = 0
  91. fix = 0
  92. do irn = 1 to total
  93. if out = "F" then do
  94.   if irn/5 = irn%5 then writech(stdout,".")
  95.   if printed = 55 then do
  96.     writeln(output," ")
  97.     writeln(output,center("The following people have birthdays "ending date1".",80))
  98.     writeln(output,"-------------------------------------------------------------------------------")
  99.     printed = 0
  100.   end
  101. end
  102. date2 = ""
  103. getbirthdate irn
  104. birth = result
  105. checkdate(birth)
  106. if check = "TRUE" then do
  107.   MakeName(irn)
  108.   getage(irn)
  109.   writeln(output,name "["right(irn,3)"]" right(birth,12) "       Age: "right(age,3))
  110.   printed = printed + 1
  111.   fix = 1
  112.   end
  113. end
  114. say
  115. if out = "F" then say printed "records found."
  116. if fix = 0 then do
  117.   writeln(output,"No birthdays were found on that date.")
  118.   end
  119. writeln(output,"===============================================================================")
  120. writeln(output,"")
  121. writeln(output,center("The following people died "ending date1".",80))
  122. writeln(output,"-------------------------------------------------------------------------------")
  123. printed = printed + 4
  124. if out = "F" then writech(stdout,"Checking Death records. ")
  125. fix = 0
  126. do irn = 1 to total
  127. if out = "F" then do
  128.   if irn/5 = irn%5 then writech(stdout,".")
  129.   if printed >= 55 then do
  130.     writeln(output," ")
  131.     writeln(output,center("The following people died "ending date1".",80))
  132.     writeln(output,"-------------------------------------------------------------------------------")
  133.     printed = 0
  134.   end
  135. end
  136. date2 = ""
  137. getdeathdate irn
  138. death = result
  139. checkdate(death)
  140. if check = "TRUE" then do
  141.   MakeName(irn)
  142.   writeln(output,name "["right(irn,3)"]" right(death,12))
  143.   printed = printed + 1
  144.   fix = 1
  145.   end
  146. end
  147. say
  148. if out = "F" then say printed "records found."
  149. if fix = 0 then do
  150.   writeln(output,"No Deaths were found on that date.")
  151.   end
  152. writeln(output,"===============================================================================")
  153.  
  154. writeln(output,"")
  155. writeln(output,center("The following people were buried "ending date1".",80))
  156. writeln(output,"-------------------------------------------------------------------------------")
  157. printed = printed + 4
  158. if out = "F" then writech(stdout,"Checking Burial records. ")
  159. fix = 0
  160. do irn = 1 to total
  161. if out = "F" then do
  162.   if irn/5 = irn%5 then writech(stdout,".")
  163.   if printed >= 55 then do
  164.     writeln(output," ")
  165.     writeln(output,center("The following people were buried "ending date1".",80))
  166.     writeln(output,"-------------------------------------------------------------------------------")
  167.     printed = 0
  168.   end
  169. end
  170. date2 = ""
  171. getburialdate irn
  172. burial = result
  173. checkdate(burial)
  174. if check = "TRUE" then do
  175.   MakeName(irn)
  176.   writeln(output,name "["right(irn,3)"]" right(burial,12))
  177.   printed = printed + 1
  178.   fix = 1
  179.   end
  180. end
  181. say
  182. if out = "F" then say printed "records found."
  183. if fix = 0 then do
  184.   writeln(output,"No burials were found on that date.")
  185.   end
  186.  
  187. writeln(output,"===============================================================================")
  188. printed = printed + 1
  189. gettotalfgrn
  190. total = result
  191. writeln(output,"")
  192. writeln(output,center("The following people have marriages "ending date1".",80))
  193. writeln(output,"-------------------------------------------------------------------------------")
  194. printed = printed + 4
  195. if out = "F" then writech(stdout,"Checking Marriage records. ")
  196. printed = 0
  197. do fgrn = 1 to total
  198. if out = "F" then do
  199.   if irn/5 = irn%5 then writech(stdout,".")
  200.   if printed >= 55 then do
  201.     writeln(output," ")
  202.     writeln(output,center("The following people have marriages "ending date1".",80))
  203.     writeln(output,"-------------------------------------------------------------------------------")
  204.     printed = 0
  205.   end
  206. end
  207. date2 = ""
  208. getmarrydate fgrn
  209. marry = result
  210. checkdate(marry)
  211. if check = "TRUE" then do
  212.   getprincipal fgrn
  213.   P = result
  214.   getspouse fgrn
  215.   S = result
  216.   MakeName(P)
  217.   Name1 = name
  218.   MakeName(S)
  219.   Name2 = name
  220.   getsex P
  221.   sex = resut
  222.   if sex = "F" then do
  223.     temp = name1
  224.     name1 = name2
  225.     name2 = temp
  226.     t = p
  227.     p = s
  228.     s = t
  229.     end
  230.     married = "been married for"
  231.     years = "years"
  232.   GetMarriageLength(fgrn)
  233.   if marriagelength > 100 then do
  234.     married = ""
  235.     marriagelength = ""
  236.     years = ""
  237.     end
  238.   if pcheck = 1 | scheck = 1 then do
  239.     married = "were married for"
  240.     end
  241.   writeln(output,Name1 "["right(p,3)"]" right(marry,12) married marriagelength years)
  242.   writeln(output,Name2 "["right(s,3)"]")
  243.   writeln(output,"")
  244.   printed = printed + 3
  245.   end
  246. end
  247. say
  248. if out = "F" then say printed "records found."
  249. if printed = 0 then do
  250.   writeln(output,"No marriagies were found on that date.")
  251.   end
  252. writeln(output,"===============================================================================")
  253. end
  254. if out = "F" then do
  255.   writeln(output," ")
  256.   close(w_file)
  257.   writeln(stdout,"")
  258.   writeln(stdout,"All Finished")
  259.   end
  260.  
  261. exit
  262.  
  263. MakeName:
  264. parse arg irn
  265. getfirstname irn
  266. name = left(result,18)
  267. getlastname irn
  268. name = name left(result,12)
  269. return name
  270.  
  271. CheckDate:
  272. parse arg date
  273. if words(date1) = 2 then date2 = word(upper(date),1)
  274. date2 = date2 word(upper(date),2)
  275. if date2 ~= "" & date1 = date2 then do
  276.   check = "TRUE"
  277.   end
  278.   else
  279.   check = "FALSE"
  280. return check
  281.  
  282. CheckMonth:
  283. parse arg m
  284. if m = "JAN" then x = 1
  285. if m = "FEB" then x = 2
  286. if m = "MAR" then x = 3
  287. if m = "APR" then x = 4
  288. if m = "MAY" then x = 5
  289. if m = "JUN" then x = 6
  290. if m = "JUL" then x = 7
  291. if m = "AUG" then x = 8
  292. if m = "SEP" then x = 9
  293. if m = "OCT" then x = 10
  294. if m = "NOV" then x = 11
  295. if m = "DEC" then x = 12
  296. return x
  297.  
  298. GetMonth:
  299. parse arg z
  300. if z = 1 then  m = "JAN"
  301. if z = 2 then  m = "FEB"
  302. if z = 3 then  m = "MAR"
  303. if z = 4 then  m = "APR"
  304. if z = 5 then  m = "MAY"
  305. if z = 6 then  m = "JUN"
  306. if z = 7 then  m = "JUL"
  307. if z = 8 then  m = "AUG"
  308. if z = 9 then  m = "SEP"
  309. if z = 10 then  m = "OCT"
  310. if z = 11 then  m = "NOV"
  311. if z = 12 then  m = "DEC"
  312. return m
  313.  
  314. GetAge:
  315. parse arg irn
  316. age = ""
  317. life = ""
  318. day1   = subword(date(),1,1)
  319. Month1 = subword(date(),2,1)
  320. Year1  = subword(date(),3,1)
  321. CheckMonth(upper(Month1))
  322. m1 = x
  323.  
  324. birth = ""
  325. getbirthdate irn
  326. birth = result
  327. if birth ~= "" then do
  328. if length(birth) > 3 then do
  329.   day2   = word(birth,1)
  330.   Month2 = substr(word(birth,2),1,3)
  331.   Year2  = substr(birth,length(birth)-3,4)
  332.   CheckMonth(upper(Month2))
  333.   m2 = x
  334. end
  335.  
  336. death = ""
  337. getdeathdate irn
  338. death = result
  339. if length(death) > 3 then do
  340.   day3   = word(death,1)
  341.   Month3 = word(death,2)
  342.   Year3  = substr(death,length(death)-3,4)
  343.   CheckMonth(upper(Month3))
  344.   m3 = x
  345.   age = year3 - year2
  346.   if m3 < m2 then age = age -1
  347.   if m3 = m2 then do
  348.     if day3 < day2 then age = age -1
  349.    end
  350.    Life = "D"
  351. end
  352.  
  353. /* Person is still alive */
  354.  
  355. if length(death) < 3 & length(birth) > 3 then do
  356. age = year1 - year2
  357. Life = "L"
  358. if m1 < m2 then
  359.          age = age -1
  360.     if m1 = m2 then do
  361.  
  362.    if day1 < day2 then do
  363.      age = age -1
  364.      end
  365.      end
  366.      end
  367.      if age > 105 then do
  368.        age = ""
  369.        Life = ""
  370.        end
  371. end
  372. if age > 105 then age = ""
  373. return age
  374.  
  375. GetMarriageLength:
  376. parse arg fgrn
  377. day1   = subword(date(),1,1)
  378. Month1 = subword(date(),2,1)
  379. Year1  = subword(date(),3,1)
  380. CheckMonth(upper(Month1))
  381. m1 = x
  382. Marriagelength = ""
  383. if marry ~= "" then do
  384. if length(marry) > 3 then do
  385.   day2   = word(marry,1)
  386.   Month2 = substr(word(marry,2),1,3)
  387.   Year2  = substr(marry,length(marry)-3,4)
  388.   CheckMonth(upper(Month2))
  389.   m2 = x
  390.  
  391.   pcheck = 0
  392.   getdeathdate p
  393.   if result ~= "" then do
  394.     pdate = result
  395.     day1   = word(pdate,1)
  396.     Month1 = substr(word(pdate,2),1,3)
  397.     Year1  = substr(pdate,length(pdate)-3,4)
  398.     CheckMonth(upper(pMonth))
  399.     m2 = x
  400.     pcheck = 1
  401.     end
  402.  
  403.     scheck = 0
  404.   getdeathdate s
  405.   if result ~= "" then do
  406.     sdate = result
  407.     sday   = word(sdate,1)
  408.     sMonth = substr(word(sdate,2),1,3)
  409.     sYear  = substr(sdate,length(sdate)-3,4)
  410.     CheckMonth(upper(sMonth))
  411.     m3 = x
  412.     scheck = 1
  413.     end
  414.  
  415.   if pcheck = 1 & scheck = 1 then do
  416.     if year1 > syear then do
  417.       year1  = syear
  418.       month1 = smonth
  419.       day1   = sday
  420.     end
  421.   end
  422.  
  423.   if pcheck = 0 & scheck = 1 then do
  424.     year1  = syear
  425.     month1 = smonth
  426.     day1   = sday
  427.   end
  428.  
  429. /*    say "Year1 "year1
  430.   say "Year2 "year2 */
  431.   marriagelength = year1 - year2
  432.   if m1 < m2 then marriagelength = marriagelength -1
  433.   if m1 = m2 then do
  434.     if day1 < day2 then do
  435.       marriagelength = marriagelength -1
  436.     end
  437.   end
  438. end
  439. end
  440. return marriagelength
  441.  
  442.